package com.starsoft.frame.util;

import java.net.InetAddress;
import java.net.NetworkInterface;
import java.util.Locale;

public class EnvUtil {
	public static String getMac() {
		try {
			InetAddress address = InetAddress.getLocalHost();
			NetworkInterface ni = NetworkInterface.getByInetAddress(address);
			byte[] mac = ni.getHardwareAddress();
			String sMAC = "";
			for (int i = 0; i < mac.length; i++) {
				sMAC += String.format(Locale.getDefault(), "%02X%s", mac[i], (i < mac.length - 1) ? "-" : "")
						.toString();
			}
			return sMAC;
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}
}
